<!DOCTYPE html>
<html lang="en">
<head>
    <!--
    @Author 硕鼠
    @Date 2020/4/6 17:44
    @Version 1.0
    @Description innerHTML测试
  -->
    <meta charset="UTF-8">
    <title>Title</title>
    <script>
        window.onload = function () {
            var oTxt = document.getElementById('txt1');
            var oBtn = document.getElementById('btn1');
            var oDiv = document.getElementById('div1');
            oBtn.onclick = function () {
                oDiv.innerHTML = oTxt.value; //赋值给div
                // alert(oDiv.innerHTML) //将oDiv数据读出
                //也可以将HTML语句读出并展示。
            }
        }
    </script>
</head>
<body>

<input id="txt1" type="text">
<input id="btn1" type="button" value="设置文字">
<div id="div1">
    abct
</div>
</body>
</html>